#include "resample_classifier.h"
#include "factory.h"
#include "resampler.h"

#include <iostream>

bool resample_classifier::train(boosting_problem & prob, double * d_t, int argc, char ** argv) {

	factory fact;
	resampler * rsplr = fact.get_resampler(argv[0]);
	argc --;
	argv ++;

	boosting_problem selected_prob;
	if(!rsplr->resample_problem(prob, d_t, argc, argv, selected_prob)) {
		rsplr->destroy_problem(selected_prob);
		delete rsplr;
		return false;
	}

	int pn = 0;
	for(int i = 0; i < selected_prob.l; i++) {
		if(selected_prob.y[i] == 1) {
			pn ++;
		}
	}

	cout << pn << " positive, " << selected_prob.l-pn << " negative. ";

	train(selected_prob, argc, argv);

	rsplr->destroy_problem(selected_prob);
	delete rsplr;

	return true;
}
